from django.db import models


# Create your models here.

class OrderInfo(models.Model):
    ORDER_STATUS = (
        (-1, '下单失败'),
        (1, '下单成功'),
        (2, '已取消'),
        (3, '已关闭')
    )

    PAY_STATUS = (
        (-1, '支付失败'),
        (0, '等待支付'),
        (1, '支付中'),
        (2, '支付成功')
    )
    ORDER_TYPE = (
        (1, '商家订单'),
        (2, '代理订单')
    )
    IS_SEND = (
        (0, '未发卡'),
        (1, '已发卡')
    )
    order_no = models.CharField(max_length=68, unique=True, null=False, verbose_name='订单号')
    business_code = models.IntegerField(unique=False, null=False, verbose_name='商户编号')
    buyer_phone = models.CharField(max_length=11, unique=False, null=False, verbose_name='卖家手机号')
    buyer_email = models.CharField(max_length=128, unique=False, null=True, verbose_name='买家邮箱')
    block_code = models.CharField(max_length=68, unique=False, null=False, verbose_name='区组编号')
    sale_phone = models.CharField(max_length=11, unique=False, null=False, verbose_name='卖家手机(账户手机号)')
    distribution_scale = models.DecimalField(max_digits=10, decimal_places=2, unique=False, null=True, verbose_name='分销比例')
    pay_amount = models.DecimalField(max_digits=10, decimal_places=2, unique=False, null=False, verbose_name='支付金额')
    order_status = models.IntegerField(choices=ORDER_STATUS, unique=False, null=False, verbose_name='订单状态')
    pay_status = models.IntegerField(choices=PAY_STATUS, unique=False, null=False, verbose_name='支付状态')
    pay_way_code = models.CharField(max_length=20, unique=False, null=False, verbose_name='支付方式')
    out_pay_code = models.CharField(max_length=68, unique=False, null=False, verbose_name='外部支付编号')
    order_type = models.IntegerField(choices=ORDER_TYPE, unique=False, null=False, verbose_name='订单类型')
    pay_time = models.DateTimeField(unique=False, null=True, verbose_name='支付时间')
    is_send = models.IntegerField(choices=IS_SEND, unique=False, null=False, verbose_name='是否发卡')
    created_time = models.DateTimeField(unique=False, null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(unique=False, null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'order_info'
        verbose_name = '订单信息'
        verbose_name_plural = verbose_name


class OrderDetail(models.Model):
    order_no = models.CharField(max_length=68, unique=False, null=False, verbose_name='订单号')
    card_code = models.CharField(max_length=68, unique=True, null=False, verbose_name='卡片编号')
    business_code = models.IntegerField(unique=False, null=False, verbose_name='商户编号')

    class Meta:
        db_table = 'order_detail'
        verbose_name = '订单详情信息'
        verbose_name_plural = verbose_name
